# Maintainer: Marcelo Duarte https://github.com/marcelotduarte

_realname=cx-logging
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.0
pkgrel=2
pkgdesc="Python and C interfaces for logging (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
license=('PSF')
url="https://github.com/anthony-tuininga/cx_Logging"
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('staticlibs' 'strip' '!debug')
source=(cx_Logging-${pkgver}.tar.gz::https://pypi.io/packages/source/c/cx_Logging/cx_Logging-${pkgver}.tar.gz
        0000-include-cx-logging-h.patch)
sha256sums=('ba8a7465facf7b98d8f494030fb481a2e8aeee29dc191e10383bb54ed42bdb34'
            'f5485235eb2ecdbf6fd88f4ff18fb37572c8a75a8e52eaba124b63e6e2938ff4')

apply_patch_with_msg() {
  for _patch in "$@"
  do
    msg2 "Applying ${_patch}"
    patch -Nbp1 -i "${srcdir}/${_patch}"
  done
}

prepare() {
  # patch cx_Logging 3.0 - temporary fix until 3.1
  apply_patch_with_msg 0000-include-cx-logging-h.patch
  rm -Rf python-${_realname}-${CARCH}
  cp -a cx_Logging-${pkgver} python-${_realname}-${CARCH}
}

package() {
  local _mingw_prefix=$(cygpath -wm ${MINGW_PREFIX})
  cd python-${_realname}-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1
}
